import { createBrowserRouter, createHashRouter, Navigate } from 'react-router-dom';
import React, { lazy, Suspense } from 'react';
import Main from '../layouts/main';
import Sloader from '../conponents/sLoader';
import HOCRouter from './HocRouter';
// const Login = lazy(() => import('../views/login/index'));
// const UserManagement = lazy(() => import('../views/userManagement'));
// const RoleManagement = lazy(() => import('../views/roleManagement'));
// const PermissionManagement = lazy(() => import('../views/permissionManagement'));
// const upload = lazy(() => import('../views/uploadFile/index'));
// const MediaManagement = lazy(() => import('../views/mediaManagement'));
// const MediaCategory = lazy(() => import('../views/mediaCategory'));
// const NoFounted = lazy(() => import('../views/404'));
import Login from '../views/login/index';
import UserManagement from '../views/userManagement';
import RoleManagement from '../views/roleManagement';
import PermissionManagement from '../views/permissionManagement';
import Upload from '../views/uploadFile/index';
import MediaManagement from '../views/mediaManagement';
import MediaCategory from '../views/mediaCategory';
import NoFounted from '../views/404';
import Rg from '@/views/rg';
import Trial from '@/views/trial/trial';
// import {Navigate} from "react-router-dom";
// 包裹路由的组件
const LazyWrapper = (Component) => (
  <Suspense fallback={<Sloader />}>
    <Component />
  </Suspense>
);

const router = createHashRouter([
  {
    path: '/',
    element: (
      <HOCRouter>
        <Main />
      </HOCRouter>
    ),
    children: [
      {
        index: true,
        element: <UserManagement />,
      },
      {
        path: '/roleManagement',
        element: <RoleManagement />,
      },
      {
        path: '/permissionManagement',
        element: <PermissionManagement />,
      },
      {
        path: '/upload',
        element: <Upload />,
      },
      {
        path: '/mediaManagement',
        element: <MediaManagement />,
        children: [
          {
            path: '/mediaManagement/camera1',
            element: <div>摄像头1</div>,
          },
          {
            path: '/mediaManagement/camera2',
            element: <div>摄像头2</div>,
          },
          {
            path: '/mediaManagement/camera3',
            element: <div>摄像头3</div>,
          },
        ],
      },
      {
        path: '/MediaCategory',
        element: <MediaCategory />,
      },
      {
        path: '/dd',
        element: <div>钉钉</div>,
      },
      {
        path: '/qywx',
        element: <div>企业微信</div>,
      },
      {
        path: '/pdd',
        element: <div>拼多多</div>,
      },
      {
        path: '/zdh',
        element: <div>自动化</div>,
      },
      {
        path: '/rg',
        element: <Rg />,
      },
      {
        path: '/trial',
        element: <Trial></Trial>,
      },
    ],
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '*',
    element: <NoFounted />,
  },
]);

export default router;
